var pictureUploadRight = false;
var attachUploadRight = false;

function verifyForm() {
	return true;
}

function ajaxPictureUpload() {
	$("#picLoading")
	.ajaxStart(function(){
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide();
	});

	$.ajaxFileUpload ({
		url: "admin/uploadBookImage.do",
		secureuri: false,
		fileElementId: "picture", 
		dataType: "text/xml", 
		success: function (data, status) {
			$("#picPath").val(data.substring(5, data.indexOf("</pre>")));
			pictureUploadRight = true;
		},
		error: function (data, status, e) {
			alert("error: " + data + ", " + status + ", " + e);
			pictureUploadRight = false;
		}
	})
}

function ajaxAttachUpload() {
	attachUploadRight = true;
}

function addBook() {
	if (verifyForm()) {
		ajaxPictureUpload();
		ajaxAttachUpload();
		return pictureUploadRight && attachUploadRight;
	} else {
		return false;
	}
}